package com.andy.app_core.net;


import com.andy.app_core.net.callback.IError;
import com.andy.app_core.net.callback.IFailure;
import com.andy.app_core.net.callback.IRequest;
import com.andy.app_core.net.callback.ISuccess;

import java.io.File;
import java.util.HashMap;

import okhttp3.RequestBody;

/**
 * @version V1.0
 * @描述:
 * @Company:
 * @auth: Created by AN .
 * @time: 2020/3/26 15:59
 * @des
 */
public class RestClientBuilder {
    private HashMap<String,Object> mParams;
    private String mUrl;
    private IRequest mRequest;
    private ISuccess mSuccess;
    private IError mError;
    private IFailure mFailure;
    private RequestBody mBody;

    //上传下载
    private File mFile;
    private String mDownloadDir;
    private  String mExtension;
    private  String mFilename;

    public RestClientBuilder() {
    }
    public final RestClientBuilder url(String url){
        this.mUrl=url;
        return this;
    }
    public final RestClientBuilder parms(HashMap<String,Object> parms){
        this.mParams=parms;
        return this;
    }
    public final RestClientBuilder request(IRequest request){
        this.mRequest=request;
        return this;
    }
    public final RestClientBuilder success(ISuccess success){
        this.mSuccess=success;
        return this;
    }
    public final RestClientBuilder failure(IFailure failure){
        this.mFailure=failure;
        return this;
    }
    public final RestClientBuilder error(IError error){
        this.mError=error;
        return this;
    }
    public final RestClientBuilder body(RequestBody body){
        this.mBody=body;
        return this;
    }

    //上传
    public final RestClientBuilder file(File file){
        this.mFile=file;
        return this;
    }
    public final RestClientBuilder file(String file){
        this.mFile=new File(file);
        return this;
    }
    //下载
    public final RestClientBuilder dir(String dir){
        this.mDownloadDir=dir;
        return this;
    }
    public final RestClientBuilder extension(String extension){
        this.mExtension=extension;
        return this;
    }
    public final RestClientBuilder filename(String filename){
        this.mFilename=filename;
        return this;
    }

    public final RestClient build(){
        return new RestClient(mParams,mUrl,mRequest,mSuccess,mFailure,mError,mBody,mFile,mDownloadDir,mExtension,mFilename);
    }
}
